home *** CD-ROM | disk | FTP | other *** search
Lisp/Scheme | 1988-04-07 | 1.2 KB | 36 lines | [TEXT/ttxt] |
- ;; Larry Mulcahy 1988
- ;; primitive s-expression functions for sequence
-
- (provide 's-expression-primitive)
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; list:position
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; return the 0-origin position of the first occurrence of the
- ; element e in the list l.
- ; If not found, return nil.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun list:position (e l)
- (dotimes (i (length l) nil)
- (if (equal e (nth i l))
- (return i))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; list:position-if
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun list:position-if (test l)
- (dotimes (i (length l) nil)
- (if (funcall test (nth i l)) (return i))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; list:position-if-not
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun list:position-if-not (test l)
- (dotimes (i (length l) nil)
- (if (not (funcall test (nth i l))) (return i))))
-
-
-